package com.pocket.demo.core.security;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * @author zhaozhile
 */
@Getter
@Setter
public class PocketUser implements UserDetails, Serializable {
    private static final Log logger = LogFactory.getLog(User.class);
    private String password;
    private String username;
    private Set<GrantedAuthority> authorities;
    private boolean accountNonExpired;
    private boolean accountNonLocked;
    private boolean credentialsNonExpired;
    private boolean enabled;
    private Set<String> permissions;

    public PocketUser(){

    }
    public PocketUser(String username, String password, Set<GrantedAuthority> authorities) {
        this(username, password, authorities,true, true, true, true,  new HashSet<>());
    }

    public PocketUser(String username, String password, Set<GrantedAuthority> authorities, Set<String> permissions) {
        this(username, password, authorities,true, true, true, true,  permissions);
    }

    public PocketUser(String username, String password, Set<GrantedAuthority> authorities, boolean accountNonExpired, boolean accountNonLocked, boolean credentialsNonExpired, boolean enabled, Set<String> permissions) {
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.accountNonExpired = accountNonExpired;
        this.accountNonLocked = accountNonLocked;
        this.credentialsNonExpired = credentialsNonExpired;
        this.enabled = enabled;
        this.permissions = permissions;
    }
}
